<?php

use Illuminate\Database\Seeder;

class BasePictureSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $spot_ids = \App\Model\Spot::all()->pluck('id')->toArray();

        $user_ids = \App\Model\User::all()->pluck('id')->toArray();

        $faker = app(Faker\Generator::class);

        $base_picture = factory(\App\Model\BasePicture::class)
            ->times(1000)
            ->make()
            ->each(function ($value)
            use($spot_ids,$user_ids,$faker) {
                $value->spot_id = $faker->randomElement($spot_ids);
                $value->user_id = $faker->randomElement($user_ids);
        });
        \App\Model\BasePicture::insert($base_picture->toArray());
    }
}
